<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>编辑问题</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/public/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/public/layuiadmin/style/admin.css" media="all">
</head>
<body>
#{set helpDto:help.get('list').get(0)/}
<div class="layui-fluid">
    <div class="layui-card">
        <div style="height: 42px;line-height: 42px;padding: 0 15px;border-bottom: 1px solid #f6f6f6;color: #333;border-radius: 2px 2px 0 0;font-size: 14px;">
            <span><i id="return" class="layui-icon layui-icon-return" style="padding-right: 10px;"></i></span>
            <span>编辑问题</span>
        </div>
        <div class="layui-card-body" style="padding: 15px;">
            <form class="layui-form" action="" lay-filter="component-form-group">
                <input type="hidden" name="id" value="${helpDto.get('id').getAsInt()}">

                <div class="layui-form-item">
                    <label class="layui-form-label">标题</label>
                    <div class="layui-input-block">
                        <input type="text" name="title" value="${helpDto.get('title').getAsString()?.raw()}" style="width:500px" lay-verify="required" autocomplete="off" placeholder="请输入标题" class="layui-input">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">内容</label>
                    <div class="layui-input-block" style="width: 1080px">
                        <textarea id="content" placeholder="请输入内容" name="content" class="layui-textarea" lay-verify="required">${helpDto.get('content').getAsString()?.raw()}</textarea>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">排序号</label>
                    <div class="layui-input-inline">
                        <input type="text" name="orderIndex" value="${helpDto.get('orderIndex').getAsInt()}" autocomplete="off" placeholder="请输入排序号" class="layui-input">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">类型</label>
                    <div class="layui-input-inline" style="width: 150px;">
                        <select class="layui-input" name="visual" lay-verify="required">
                            <option value="１" #{if helpDto.get('type').getAsInt()==1} selected="" #{/if}>使用说明</option>
                            <option value="０" #{if helpDto.get('type').getAsInt()==0} selected="" #{/if}>问题说明</option>
                        </select>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">是否展示</label>
                    <div class="layui-input-inline" style="width: 150px;">
                        <select class="layui-input" name="visual" lay-verify="required">
                            <option value="１" #{if helpDto.get('visual').getAsInt()==1} selected="" #{/if}>是</option>
                            <option value="０" #{if helpDto.get('visual').getAsInt()==0} selected="" #{/if}>否</option>
                        </select>
                    </div>
                </div>

                <div class="layui-form-item layui-layout-admin">
                    <div class="layui-input-block">
                        <div class="layui-footer" style="left: 0;">
                            <button class="layui-btn" lay-submit="" lay-filter="component-form-demo1">提交</button>
                            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                        </div>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<script src="/public/layuiadmin/layui/layui.js"></script>
<script>
    layui.config({
        base: '/public/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'form','layer','layedit'], function(){
        var $ = layui.$
                //,admin = layui.admin
                ,layer = layui.layer
                ,layedit = layui.layedit
                ,form = layui.form;

        $(document).on('click','#return',function(){
            window.location.href = "/sys/helpList";
        });

        //初始化建立编辑器
        var indexDesc= layedit.build('content',{tool: [
                'html'//源码模式
                ,'strong', 'italic', 'underline', 'del'
                ,'addhr' //添加水平线
                ,'|', 'fontFomatt','fontfamily','fontSize' //段落格式，字体样式，字体大小
                , 'fontBackColor','colorpicker'   //字体背景色,字体颜色
                , 'face', '|', 'left', 'center', 'right', '|', 'link', 'unlink'
                , '|', 'table'//插入表格
                ,'customlink'//插入自定义链接
                ,'fullScreen'//全屏
                ,'preview'//预览
            ],height:'500px'
        });

        /* 监听提交 */
        form.on('submit(component-form-demo1)', function(data){
            var data=data.field;
            //编辑器赋值
            var content = layedit.getContent(indexDesc);
            data.content = content;
            if(content.length===0){
                return layer.msg('内容不能为空');
            }
            layedit.sync(indexDesc);
            $.post("/sys/saveHelp", data, function (result) {
                if (result.code > 0) {
                    layer.msg(result.msg, {icon:2});
                } else {
                    window.location.href = "/sys/helpList";
                }
            });
            return false;
        });
    });
</script>
</body>
</html>
